<h1>ColorTransform</h1>

<p>ColorTransform is used to change the colour of a shape or button without 
changing the values in the original definition. Two types of transformation are 
supported: <b>Add</b> and <b>Multiply</b></p>

<p>In Add transformations a value is added to each colour channel:</p>

<pre>
newRed = red + addRedTerm
newGreen = green + addGreenTerm
newBlue = blue + addBlueTerm
newAlpha = alpha + addAlphaTerm
</pre>

<p>In Multiply transformations each colour channel is multiplied by a given value:</p>

<pre>
newRed = red * multiplyRedTerm
newGreen = green * multiplyGreenTerm
newBlue = blue * multiplyBlueTerm
newAlpha = alpha * multiplyAlphaTerm
</pre>

<p>Add and Multiply transforms may be combined in which case the multiply terms are
applied to the colour channel before the add terms.</p>

<pre>
newRed = (red * multiplyRedTerm) + addRedTerm
newGreen = (green * multiplyGreenTerm) + addGreenTerm
newBlue = (blue * multiplyBlueTerm) + addBlueTerm
newAlpha = (alpha * multiplyAlphaTerm) + addAlphaTerm
</pre>

<p>For each type of transform the result of the calculation is limited to the 
range 0..255. If the result is less than 0 or greater than 255 then it is 
clamped at 0 and 255 respectively.</p>

table class="datasheet">

<tr>
<th nowrap>Field Name</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">hasAddTerms</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>Set if add terms for the colour transform are defined.</td>
</tr>

<tr>
<td nowrap valign="top">hasMultiplyTerms</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>Set if multiply terms for the colour transform are defined.</td>
</tr>

<tr>
<td nowrap valign="top">size</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">4</td>
<td>The number of bits used for each term.</td>
</tr>

<tr>
<td nowrap valign="top">multiplyRed</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">size</td>
<td>The multiply term for the red colour channel.</td>
</tr>

<tr>
<td nowrap valign="top">multiplyGreen</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">size</td>
<td>The multiply term for the green colour channel.</td>
</tr>

<tr>
<td nowrap valign="top">multiplyBlue</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">size</td>
<td>The multiply term for the blue colour channel.</td>
</tr>

<tr>
<td nowrap valign="top">multiplyAlpha</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">size</td>
<td>Optional. The multiply term for the alpha channel.</td>
</tr>


<tr>
<td nowrap valign="top">addRed</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">size</td>
<td>The add term for the red colour channel.</td>
</tr>

<tr>
<td nowrap valign="top">addGreen</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">size</td>
<td>The add term for the green colour channel.</td>
</tr>

<tr>
<td nowrap valign="top">addBlue</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">size</td>
<td>The add term for the blue colour channel.</td>
</tr>

<tr>
<td nowrap valign="top">addAlpha</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">size</td>
<td>Optional. The add term for the alpha channel.</td>
</tr>

</table>

<p>Not all objects containing a colour transform use the add or multiply terms 
defined for the alpha channel. The colours defined in an DefineButton, 
ButtonColorTransform or PlaceObject instruction do not use the alpha channel. 
Transparent colours were introduced in Flash 3. The instruction that contains 
the colour transform controls whether the alpha channel information is encoded 
or not. Simply specifying the alpha channel is not sufficient.</p>

<h2>History</h2>

<p>The ColorTransform represents the CXForm and CXFormWithAlpha data structures 
described in the Macromedia Flash (SWF) File Format Specification. They were 
introduced in Flash 1 and Flash 3 respectively.</P>
